package com.example.springboot.common.vo;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageUtils implements Serializable {
	private static final long serialVersionUID = -1202716581589799959L;

	//总记录数
	private int count;
	//每页记录数
	private int limit;
	//总页数
	private int totalPage;
	//当前页数
	private int page;
	//列表数据
	private List<?> list;

	/**
	 * 分页
	 *
	 * @param list  列表数据
	 * @param count 总记录数
	 * @param limit 每页记录数
	 * @param page  当前页数
	 */
	public PageUtils(List<?> list, int count, int limit, int page) {
		this.list = list;
		this.count = count;
		this.limit = limit;
		this.page = page;
		this.setTotalPage((int) Math.ceil((double) count / limit));
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public List<?> getList() {
		return list;
	}

	public void setList(List<?> list) {
		this.list = list;
	}
}